home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / haeberli / impression / ssscale.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  2KB  |  71 lines

  1. /*
  2.  * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /*
  18.  *    ssscale - 
  19.  *        Scale a sample set
  20.  *
  21.  *            Paul Haeberli - 1988
  22.  */
  23. #include "stdio.h"
  24. #include "ss.h"
  25. #include "math.h"
  26.  
  27. #define COLOR        1
  28. #define DIRECTION    2
  29. #define POSITION    4
  30. #define SIZE        8
  31.  
  32. main(argc,argv)
  33. int argc;
  34. char **argv;
  35. {
  36.     sampleset *iss, *oss;
  37.     float mag;
  38.     int i;
  39.  
  40.     if( argc<4 ) {
  41.     fprintf(stderr,"usage: ssscale in.ss out.ss mag\n");
  42.     exit(1);
  43.     } 
  44.     mag = atof(argv[3]);
  45.     iss = ssfromfile(argv[1]);
  46.     oss = ssnew();
  47.     ssscale(iss,oss,mag);
  48.     sstofile(argv[2],oss);
  49. }
  50.  
  51. ssscale(iss,oss,mag)
  52. sampleset *iss, *oss; 
  53. float mag;
  54. {
  55.     sample *s, *ns;
  56.     int imag, bimag;
  57.     int size;
  58.  
  59.     s = iss->head;
  60.     while(s) {
  61.     ns = sclone(s);
  62.     size = mag*ns->at0;
  63.     if(size>255)
  64.         size = 255;
  65.     ns->at0 = size;
  66.     addsample(oss,ns);
  67.     s = s->next;
  68.     }
  69. }
  70.  
  71.